<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <table id="tb"  width="40%" border="1" cellpadding="10" style="background-color: pink;">
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>操作</th>
        </tr>
        <tr>
            <td>001</td>
            <td>zhangsan</td>
            <td><a href="javascript:void(0)" onclick="delRow(this)">删除</a></td>
        </tr>
        <tr>
            <td>002</td>
            <td>李四</td>
            <td><a href="javascript:void(0)" onclick="delRow(this)">删除</a></td>
        </tr>

    </table>
    <br>
    学号: <input type="text" id="uid">姓名： <input type="text" name="" id="name"> <input type="button" value="添加一行数据" name="" id="btn">

<script>
    let trs = document.getElementsByTagName("tr");
    for (let tr of trs) {
        tr.onmouseover = function () {
            tr.style.backgroundColor  = 'red';
        }
        tr.onmouseout = function () {
            tr.style.backgroundColor  = 'yellow';
        }
    }

    let ins = document.getElementsByTagName("input");
    ins[2].onclick = function () {
        let uid = ins[0].value;
        let name = ins[1].value;
        ins[0].value = '';
        ins[1].value = '';

        let tb = document.getElementById("tb");

        tb.innerHTML +="\n" +
                        "        <tr>\n" +
                        "            <td>"+uid+"</td>\n" +
                        "            <td>"+name+"</td>\n" +
                        "            <td><a href=\"javascript:void(0)\" onclick=\"delRow(this)\">删除</a></td>\n" +
                        "        </tr>"
    }

   function delRow(obj){
       if (confirm("确定要删除这一行吗")) {
            let node = obj.parentNode.parentNode;
            node.remove();
       }
   }


</script>
</body>
</html>